package com.seeyon.apps.kk.form.workflowevent;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

import com.seeyon.apps.collaboration.po.ColSummary;
import com.seeyon.apps.kk.manager.FreemarkFlowManager;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.cap4.form.bean.FormDataSubBean;
import com.seeyon.cap4.form.bean.FormTableBean;
import com.seeyon.ctp.common.constants.ApplicationCategoryEnum;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.workflow.event.AbstractWorkflowEvent;
import com.seeyon.ctp.workflow.event.WorkflowEventData;
import com.seeyon.ctp.workflow.event.WorkflowEventResult;
import com.seeyon.kk.utils.CAP4FormKitUtils;
import com.seeyon.kk.utils.ValueUtils;

/**
 *
 * 邀请函发起后事件
 * 
 * @author Administrator
 *
 */
public class SalesClhExtendPlug1 extends KkBaseExtendPlug {
	private static final Log log = LogFactory.getLog(SalesClhExtendPlug1.class);

	@Override
	public String getId() {
		// TODO Auto-generated method stub
		return "sALESCLHExtendPlug1";
	}

	@Override
	public String getLabel() {
		// TODO Auto-generated method stub
		return "sales处理事件1";
	}

	@Override
	public ApplicationCategoryEnum getAppName() {
		return ApplicationCategoryEnum.form;
	}

	// 发起事件
	public void onFinishWorkitem(WorkflowEventData data) {
		Map<String, Object> formMap = data.getBusinessData();
		FormDataMasterBean fdmb = (FormDataMasterBean) formMap.get("formDataBean");
		ColSummary colSummary=(ColSummary)data.getSummaryObj();
		if(colSummary!=null) {
			log.info("kk:colSummarygetFormRecordid"+colSummary.getFormRecordid());
			log.info("kk:colSummary"+colSummary.getId());
		}

		String salesUpdateZt = this.freemarkFlowManager.fltTemplateIntoString("invitation/salesSp.ftl", colSummary);
		log.info("kk:salesUpdateZt" + salesUpdateZt);
		this.kkJdbcTemplate.update(salesUpdateZt);

//		CAP4FormKitUtils.setCellValue(formDataMasterBean, "field0040", "待财务审批");
//
//		try {
//			this.cap4FormManager.saveOrUpdateFormData(formDataMasterBean, formBean.getId(), true);
//		} catch (Exception e) {
//			log.info("kk:error" + e.getMessage());
//			e.printStackTrace();
//		}

	}

}
